Imports System.Drawing
Imports System.Windows.Forms
Imports Vintasoft.Imaging
Imports Vintasoft.Imaging.Codecs

Namespace Imaging
	Public Partial Class ThumbnailAppearanceSettingsForm
		Inherits Form

		#Region "Fields"

		Private _thumbnailAppearance As ThumbnailAppearance

		#End Region



		#Region "Constructors"

		Public Sub New()
			InitializeComponent()

			borderStyleComboBox.Items.Add(ButtonBorderStyle.None)
			borderStyleComboBox.Items.Add(ButtonBorderStyle.Dotted)
			borderStyleComboBox.Items.Add(ButtonBorderStyle.Dashed)
			borderStyleComboBox.Items.Add(ButtonBorderStyle.Solid)
			borderStyleComboBox.Items.Add(ButtonBorderStyle.Inset)
			borderStyleComboBox.Items.Add(ButtonBorderStyle.Outset)
		End Sub

		Public Sub New(thumbnailAppearance As ThumbnailAppearance)
			Me.New()
			_thumbnailAppearance = thumbnailAppearance

			ShowSettings()
		End Sub

		#End Region



		#Region "Methods"

		Private Sub ShowSettings()
			backColorPanel.BackColor = _thumbnailAppearance.BackColor
			borderColorPanel.BackColor = _thumbnailAppearance.BorderColor
			borderWidthNumericUpDown.Value = _thumbnailAppearance.BorderWidth
			borderStyleComboBox.SelectedItem = _thumbnailAppearance.BorderStyle
		End Sub

		Private Function SetSettings() As Boolean
			_thumbnailAppearance.BackColor = backColorPanel.BackColor
			_thumbnailAppearance.BorderColor = borderColorPanel.BackColor
			_thumbnailAppearance.BorderWidth = CInt(Math.Truncate(borderWidthNumericUpDown.Value))
			_thumbnailAppearance.BorderStyle = CType(borderStyleComboBox.SelectedItem, ButtonBorderStyle)

			Return True
		End Function

		Private Sub buttonOk_Click(sender As Object, e As EventArgs)
			If SetSettings() Then
				DialogResult = DialogResult.OK
			End If
		End Sub

		Private Sub buttonCancel_Click(sender As Object, e As EventArgs)
			DialogResult = DialogResult.Cancel
		End Sub

		Private Sub backColorButton_Click(sender As Object, e As EventArgs)
			colorDialog1.Color = backColorPanel.BackColor
			If colorDialog1.ShowDialog() = DialogResult.OK Then
				backColorPanel.BackColor = colorDialog1.Color
			End If
		End Sub

		Private Sub borderColorButton_Click(sender As Object, e As EventArgs)
			colorDialog1.Color = borderColorPanel.BackColor
			If colorDialog1.ShowDialog() = DialogResult.OK Then
				borderColorPanel.BackColor = colorDialog1.Color
			End If
		End Sub

		#End Region

	End Class
End Namespace
